home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr52
/
saveke.zip
/
SAVEKEY.PRG
Wrap
Text File
|
1993-04-22
|
12KB
|
295 lines
/*
* File......: SAVEKEY.PRG
* Author....: Dale Armstrong
* CIS ID....: 72730, 1104
* Date......: $Date:
* Revision..: $Revision:
* Log file..: $Logfile:
*
* This is an original work by Dale Armstrong and is placed in the
* public domain.
*
* Modification history:
* ---------------------
*
* $Log:
*
*/
/* $DOC$
* $FUNCNAME$
* FT_SAVEKEY()
* $CATEGORY$
* Keyboard/Mouse
* $ONELINER$
* Save the status of all SetKeys to an array.
* $SYNTAX$
* FT_SAVEKEY() -> aRet
* $ARGUMENTS$
* $RETURNS$
* a multi-dimensional array of the following definition:
* { { <Inkey Code>, <SetKey() Value> } }.
* $DESCRIPTION$
* FT_SAVEKEY() saves the status of all SetKeys() to a
* multi-dimensional array for later restoration
* using the function FT_RESTKEY().
*
* The SetKey definitions have been taken from the Clipper
* Header file "inkey.ch" provided by Nantucket.
*
* This effectively disables the access to hotkeys
* when necessary, i.e., to stop recursion, or to limit
* the user's actions while in other routines such as a
* call to help.
* $EXAMPLES$
*
* // called by the F1 key, Clipper 5.01 default
* FUNCTION help( <Proc>, <Line>, <Var> )
* LOCAL aOldSetKeys
* .. other variable declarations
*
* // store all SET KEY's
* aOldSetKeys := FT_SAVEKEY()
*
* .. program's code
*
* // restore old KEY SET's
* FT_RESTKEY( aOldSetKeys )
*
* RETURN nil
* $SEEALSO$
* FT_SAVEKEY()
* $END$
*/
#include "inkey.ch"
FUNCTION SaveKeys()
LOCAL aSetKey := {}
// Cursor movement keys
aAdd( aSetKey, { K_UP , SetKey( 5 ) } ) // Uparrow, Ctrl-E
aAdd( aSetKey, { K_DOWN , SetKey( 24) } ) // Dnarrow, Ctrl-X
aAdd( aSetKey, { K_LEFT , SetKey( 19) } ) // Leftarrow, Ctrl-S
aAdd( aSetKey, { K_RIGHT, SetKey( 4 ) } ) // Rightarrow, Ctrl-D
aAdd( aSetKey, { K_HOME , SetKey( 1 ) } ) // Home, Ctrl-A
aAdd( aSetKey, { K_END , SetKey( 6 ) } ) // End, Ctrl-F
aAdd( aSetKey, { K_PGUP , SetKey( 18) } ) // PgUp, Ctrl-R
aAdd( aSetKey, { K_PGDN , SetKey( 3 ) } ) // PgDn, Ctrl-C
aAdd( aSetKey, { K_CTRL_LEFT , SetKey( 26) } ) // Ctrl-Leftarrow, Ctrl-Z
aAdd( aSetKey, { K_CTRL_RIGHT , SetKey( 2 ) } ) // Ctrl-Rightarrow, Ctrl-B
aAdd( aSetKey, { K_CTRL_UP , SetKey( 397 ) } ) // Ctrl-Uparrow
aAdd( aSetKey, { K_CTRL_DOWN , SetKey( 401 ) } ) // Ctrl-Dnarrow
aAdd( aSetKey, { K_CTRL_HOME , SetKey( 29) } ) // Ctrl-Home, Ctrl-]
aAdd( aSetKey, { K_CTRL_END, SetKey( 23) } ) // Ctrl-End, Ctrl-W
aAdd( aSetKey, { K_CTRL_PGUP , SetKey( 31) } ) // Ctrl-PgUp, Ctrl-Hyphen
aAdd( aSetKey, { K_CTRL_PGDN , SetKey( 30) } ) // Ctrl-PgDn, Ctrl-^
aAdd( aSetKey, { K_CTRL_RET, SetKey( 10) } ) // Ctrl-Return
aAdd( aSetKey, { K_ESC , SetKey( 27) } ) // Esc, Ctrl-[
aAdd( aSetKey, { K_RETURN , SetKey( 13) } ) // Return, Ctrl-M
aAdd( aSetKey, { K_ENTER, SetKey( 13) } ) // Enter, Ctrl-M
// Editing keys
aAdd( aSetKey, { K_INS , SetKey( 22) } ) // Ins, Ctrl-V
aAdd( aSetKey, { K_DEL , SetKey( 7 ) } ) // Del, Ctrl-G
aAdd( aSetKey, { K_BS, SetKey( 8 ) } ) // Backspace, Ctrl-H
aAdd( aSetKey, { K_CTRL_BS , SetKey( 127 ) } ) // Ctrl-Backspace
aAdd( aSetKey, { K_TAB , SetKey( 9 ) } ) // Tab, Ctrl-I
aAdd( aSetKey, { K_SH_TAB , SetKey( 271 ) } ) // Shift-Tab
// Numeric keys
aAdd( aSetKey, { K_1 , SetKey( 49 ) } )
aAdd( aSetKey, { K_2 , SetKey( 50 ) } )
aAdd( aSetKey, { K_3 , SetKey( 51 ) } )
aAdd( aSetKey, { K_4 , SetKey( 52 ) } )
aAdd( aSetKey, { K_5 , SetKey( 53 ) } )
aAdd( aSetKey, { K_6 , SetKey( 54 ) } )
aAdd( aSetKey, { K_7 , SetKey( 55 ) } )
aAdd( aSetKey, { K_8 , SetKey( 56 ) } )
aAdd( aSetKey, { K_9 , SetKey( 57 ) } )
aAdd( aSetKey, { K_0 , SetKey( 48 ) } )
// Control keys
aAdd( aSetKey, { K_CTRL_DEL , SetKey( 403 ) } ) // Ctrl-DEL
aAdd( aSetKey, { K_CTRL_A, SetKey(1 ) } ) // Ctrl-A, Home
aAdd( aSetKey, { K_CTRL_B, SetKey(2 ) } ) // Ctrl-B, Ctrl-Rightarrow
aAdd( aSetKey, { K_CTRL_C, SetKey(3 ) } ) // Ctrl-C, PgDn, Ctrl-ScrollLock
aAdd( aSetKey, { K_CTRL_D, SetKey(4 ) } ) // Ctrl-D, Rightarrow
aAdd( aSetKey, { K_CTRL_E, SetKey(5 ) } ) // Ctrl-E, Uparrow
aAdd( aSetKey, { K_CTRL_F, SetKey(6 ) } ) // Ctrl-F, End
aAdd( aSetKey, { K_CTRL_G, SetKey(7 ) } ) // Ctrl-G, Del
aAdd( aSetKey, { K_CTRL_H, SetKey(8 ) } ) // Ctrl-H, Backspace
aAdd( aSetKey, { K_CTRL_I, SetKey(9 ) } ) // Ctrl-I, Tab
aAdd( aSetKey, { K_CTRL_J, SetKey(10) } ) // Ctrl-J
aAdd( aSetKey, { K_CTRL_K, SetKey(11) } ) // Ctrl-K
aAdd( aSetKey, { K_CTRL_L, SetKey(12) } ) // Ctrl-L
aAdd( aSetKey, { K_CTRL_M, SetKey(13) } ) // Ctrl-M, Return
aAdd( aSetKey, { K_CTRL_N, SetKey(14) } ) // Ctrl-N
aAdd( aSetKey, { K_CTRL_O, SetKey(15) } ) // Ctrl-O
aAdd( aSetKey, { K_CTRL_P, SetKey(16) } ) // Ctrl-P
aAdd( aSetKey, { K_CTRL_Q, SetKey(17) } ) // Ctrl-Q
aAdd( aSetKey, { K_CTRL_R, SetKey(18) } ) // Ctrl-R, PgUp
aAdd( aSetKey, { K_CTRL_S, SetKey(19) } ) // Ctrl-S, Leftarrow
aAdd( aSetKey, { K_CTRL_T, SetKey(20) } ) // Ctrl-T
aAdd( aSetKey, { K_CTRL_U, SetKey(21) } ) // Ctrl-U
aAdd( aSetKey, { K_CTRL_V, SetKey(22) } ) // Ctrl-V, Ins
aAdd( aSetKey, { K_CTRL_W, SetKey(23) } ) // Ctrl-W, Ctrl-End
aAdd( aSetKey, { K_CTRL_X, SetKey(24) } ) // Ctrl-X, Dnarrow
aAdd( aSetKey, { K_CTRL_Y, SetKey(25) } ) // Ctrl-Y
aAdd( aSetKey, { K_CTRL_Z, SetKey(26) } ) // Ctrl-Z, Ctrl-Leftarrow
// Alt keys
aAdd( aSetKey, { K_ALT_A, SetKey( 286 ) } ) // Alt-A
aAdd( aSetKey, { K_ALT_B, SetKey( 304 ) } ) // Alt-B
aAdd( aSetKey, { K_ALT_C, SetKey( 302 ) } ) // Alt-C
aAdd( aSetKey, { K_ALT_D, SetKey( 288 ) } ) // Alt-D
aAdd( aSetKey, { K_ALT_E, SetKey( 274 ) } ) // Alt-E
aAdd( aSetKey, { K_ALT_F, SetKey( 289 ) } ) // Alt-F
aAdd( aSetKey, { K_ALT_G, SetKey( 290 ) } ) // Alt-G
aAdd( aSetKey, { K_ALT_H, SetKey( 291 ) } ) // Alt-H
aAdd( aSetKey, { K_ALT_I, SetKey( 279 ) } ) // Alt-I
aAdd( aSetKey, { K_ALT_J, SetKey( 292 ) } ) // Alt-J
aAdd( aSetKey, { K_ALT_K, SetKey( 293 ) } ) // Alt-K
aAdd( aSetKey, { K_ALT_L, SetKey( 294 ) } ) // Alt-L
aAdd( aSetKey, { K_ALT_M, SetKey( 306 ) } ) // Alt-M
aAdd( aSetKey, { K_ALT_N, SetKey( 305 ) } ) // Alt-N
aAdd( aSetKey, { K_ALT_O, SetKey( 280 ) } ) // Alt-O
aAdd( aSetKey, { K_ALT_P, SetKey( 281 ) } ) // Alt-P
aAdd( aSetKey, { K_ALT_Q, SetKey( 272 ) } ) // Alt-Q
aAdd( aSetKey, { K_ALT_R, SetKey( 275 ) } ) // Alt-R
aAdd( aSetKey, { K_ALT_S, SetKey( 287 ) } ) // Alt-S
aAdd( aSetKey, { K_ALT_T, SetKey( 276 ) } ) // Alt-T
aAdd( aSetKey, { K_ALT_U, SetKey( 278 ) } ) // Alt-U
aAdd( aSetKey, { K_ALT_V, SetKey( 303 ) } ) // Alt-V
aAdd( aSetKey, { K_ALT_W, SetKey( 273 ) } ) // Alt-W
aAdd( aSetKey, { K_ALT_X, SetKey( 301 ) } ) // Alt-X
aAdd( aSetKey, { K_ALT_Y, SetKey( 277 ) } ) // Alt-Y
aAdd( aSetKey, { K_ALT_Z, SetKey( 300 ) } ) // Alt-Z
aAdd( aSetKey, { K_ALT_1, SetKey( 376 ) } ) // Alt-1
aAdd( aSetKey, { K_ALT_2, SetKey( 377 ) } ) // Alt-2
aAdd( aSetKey, { K_ALT_3, SetKey( 378 ) } ) // Alt-3
aAdd( aSetKey, { K_ALT_4, SetKey( 379 ) } ) // Alt-4
aAdd( aSetKey, { K_ALT_5, SetKey( 380 ) } ) // Alt-5
aAdd( aSetKey, { K_ALT_6, SetKey( 381 ) } ) // Alt-6
aAdd( aSetKey, { K_ALT_7, SetKey( 382 ) } ) // Alt-7
aAdd( aSetKey, { K_ALT_8, SetKey( 383 ) } ) // Alt-8
aAdd( aSetKey, { K_ALT_9, SetKey( 384 ) } ) // Alt-9
aAdd( aSetKey, { K_ALT_0, SetKey( 385 ) } ) // Alt-0
// Function keys
aAdd( aSetKey, { K_F1, SetKey( 28) } ) // F1, Ctrl-\
aAdd( aSetKey, { K_F2, SetKey( -1) } ) // F2
aAdd( aSetKey, { K_F3, SetKey( -2) } ) // F3
aAdd( aSetKey, { K_F4, SetKey( -3) } ) // F4
aAdd( aSetKey, { K_F5, SetKey( -4) } ) // F5
aAdd( aSetKey, { K_F6, SetKey( -5) } ) // F6
aAdd( aSetKey, { K_F7, SetKey( -6) } ) // F7
aAdd( aSetKey, { K_F8, SetKey( -7) } ) // F8
aAdd( aSetKey, { K_F9, SetKey( -8) } ) // F9
aAdd( aSetKey, { K_F10 , SetKey( -9) } ) // F10
aAdd( aSetKey, { K_F11 , SetKey( -40 ) } ) // F11
aAdd( aSetKey, { K_F12 , SetKey( -41 ) } ) // F12
// Control-function keys
aAdd( aSetKey, { K_CTRL_F1 , SetKey( -20 ) } ) // Ctrl-F1
aAdd( aSetKey, { K_CTRL_F2 , SetKey( -21 ) } ) // Ctrl-F2
aAdd( aSetKey, { K_CTRL_F3 , SetKey( -22 ) } ) // Ctrl-F4
aAdd( aSetKey, { K_CTRL_F4 , SetKey( -23 ) } ) // Ctrl-F3
aAdd( aSetKey, { K_CTRL_F5 , SetKey( -24 ) } ) // Ctrl-F5
aAdd( aSetKey, { K_CTRL_F6 , SetKey( -25 ) } ) // Ctrl-F6
aAdd( aSetKey, { K_CTRL_F7 , SetKey( -26 ) } ) // Ctrl-F7
aAdd( aSetKey, { K_CTRL_F8 , SetKey( -27 ) } ) // Ctrl-F8
aAdd( aSetKey, { K_CTRL_F9 , SetKey( -28 ) } ) // Ctrl-F9
aAdd( aSetKey, { K_CTRL_F10, SetKey( -29 ) } ) // Ctrl-F10
aAdd( aSetKey, { K_CTRL_F11, SetKey( -44 ) } ) // Ctrl-F11
aAdd( aSetKey, { K_CTRL_F12, SetKey( -45 ) } ) // Ctrl-F12
// Alt-function keys
aAdd( aSetKey, { K_ALT_F1 , SetKey( -30 ) } ) // Alt-F1
aAdd( aSetKey, { K_ALT_F2 , SetKey( -31 ) } ) // Alt-F2
aAdd( aSetKey, { K_ALT_F3 , SetKey( -32 ) } ) // Alt-F3
aAdd( aSetKey, { K_ALT_F4 , SetKey( -33 ) } ) // Alt-F4
aAdd( aSetKey, { K_ALT_F5 , SetKey( -34 ) } ) // Alt-F5
aAdd( aSetKey, { K_ALT_F6 , SetKey( -35 ) } ) // Alt-F6
aAdd( aSetKey, { K_ALT_F7 , SetKey( -36 ) } ) // Alt-F7
aAdd( aSetKey, { K_ALT_F8 , SetKey( -37 ) } ) // Alt-F8
aAdd( aSetKey, { K_ALT_F9 , SetKey( -38 ) } ) // Alt-F9
aAdd( aSetKey, { K_ALT_F10 , SetKey( -39 ) } ) // Alt-F10
aAdd( aSetKey, { K_ALT_F11 , SetKey( -46 ) } ) // Alt-F11
aAdd( aSetKey, { K_ALT_F12 , SetKey( -47 ) } ) // Alt-F12
// Shift-function keys
aAdd( aSetKey, { K_SH_F1, SetKey( -10 ) } ) // Shift-F1
aAdd( aSetKey, { K_SH_F2, SetKey( -11 ) } ) // Shift-F2
aAdd( aSetKey, { K_SH_F3, SetKey( -12 ) } ) // Shift-F3
aAdd( aSetKey, { K_SH_F4, SetKey( -13 ) } ) // Shift-F4
aAdd( aSetKey, { K_SH_F5, SetKey( -14 ) } ) // Shift-F5
aAdd( aSetKey, { K_SH_F6, SetKey( -15 ) } ) // Shift-F6
aAdd( aSetKey, { K_SH_F7, SetKey( -16 ) } ) // Shift-F7
aAdd( aSetKey, { K_SH_F8, SetKey( -17 ) } ) // Shift-F8
aAdd( aSetKey, { K_SH_F9, SetKey( -18 ) } ) // Shift-F9
aAdd( aSetKey, { K_SH_F10 , SetKey( -19 ) } ) // Shift-F10
aAdd( aSetKey, { K_SH_F11 , SetKey( -42 ) } ) // Shift-F11
aAdd( aSetKey, { K_SH_F12 , SetKey( -43 ) } ) // Shift-F12
aEval( aSetKey, { |aSub| SetKey( aSub[1], NIL ) } )
RETURN aSetKey
/* $DOC$
* $FUNCNAME$
* FT_RESTKEY()
* $CATEGORY$
* Keyboard/Mouse
* $ONELINER$
* Restore the status of all SetKeys from an array.
* $SYNTAX$
* FT_RESTKEY( <aToRestore> ) -> NIL
* $ARGUMENTS$
* <aToRestore> is a multi-dimensional array, created by
* the function FT_SAVEKEY, of the following definition:
* { { <Inkey Code>, <SetKey() Value> } }.
* $RETURNS$
* NIL
* $DESCRIPTION$
* FT_RESTKEY() restores the status of all SetKeys() from
* a multi-dimensional array created by the function
* FT_SAVEKEY().
*
* The SetKey definitions have been taken from the Clipper
* Header file "inkey.ch" provided by Nantucket.
*
* This effectively re-enables the access to hotkeys
* when returning from another routine such as a
* call to help.
* $EXAMPLES$
*
* // called by the F1 key, Clipper 5.01 default
* FUNCTION help( <Proc>, <Line>, <Var> )
* LOCAL aOldSetKeys
* .. other variable declarations
*
* // store all SET KEY's
* aOldSetKeys := FT_SAVEKEY()
*
* .. program's code
*
* // restore old KEY SET's
* FT_RESTKEY( aOldSetKeys )
*
* RETURN nil
* $SEEALSO$
* FT_SAVEKEY()
* $END$
*/
FUNCTION RestKeys( aPassed )
/* reset all the SET KEY's */
aEval( aPassed, { | aSub | SetKey( aSub[1], aSub[2] ) } )
RETURN nil